<?php
if (!isset($_COOKIE['foo'])) {
	setcookie('foo', 2);
} else {
	if ($_COOKIE['foo'] < 12) {
		setcookie('foo', $_COOKIE['foo'] + 2);
		printf($_COOKIE['foo']);
	} else {
		setcookie('foo', 2);
	}
}
